package com.apes.scm.stock.inventory.model;

import com.apes.framework.jpa.BaseModel;
import com.apes.framework.jpa.DefaultPersistListener;
import com.apes.framework.jpa.comment.Comment;
import com.apes.framework.jpa.generator.ApesGenerator;
import com.apes.framework.util.ApesConst;
import com.apes.scm.masterdata.enumeration.model.Enumeration;

import lombok.Getter;
import lombok.Setter;
import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;
import org.hibernate.annotations.SelectBeforeUpdate;

import javax.persistence.*;
import javax.validation.constraints.NotNull;


@Getter
@Setter
@SelectBeforeUpdate
@DynamicInsert
@DynamicUpdate
@Entity
@EntityListeners(DefaultPersistListener.class)
@Table(name = InventoryResolveRecord.CONST_TABLE_NAME)
public class InventoryResolveRecord extends BaseModel {
    public static final String CONST_TABLE_NAME = "sto_inventory_resolve_record";


    @Id
    @Column(name = "id")
    @Comment("记录编码")
    @ApesGenerator(code = CONST_TABLE_NAME, padding = 1, name = "盘点差异处理记录")
    private String id; // 唯一编码

    @NotNull
    @ManyToOne(fetch = FetchType.LAZY)
    @Comment("盘点差异编码")
    @JoinColumn(name = "inventory_diff_compound_id", referencedColumnName = "id")
    private InventoryDiffCompound InventoryDiffCompound;

    @Comment("来源单号")
    private String source;

    @ManyToOne(fetch = FetchType.LAZY)
    @Comment("来源单据类型")
    @JoinColumn(name = "inventory_source_type", referencedColumnName = "id", nullable = false)
    private Enumeration InventorySourceType;

    @Comment("处理数量")
    @Column(name = "qty_resolve", nullable = false, columnDefinition = ApesConst.FIELD_QTY_16_4_0)
    private double qtyResolve = 0;

    @Comment("备注")
    @Column(name = "remark", length = 4000)
    private String remark;

}
